//
//  CMDBFilterTableViewCell.swift
//  CMDB
//
//  Created by 曹桂祥 on 17/4/26.
//  Copyright © 2017年 CMDB. All rights reserved.
//

import UIKit

private let KSideSlipLeading : CGFloat   = 60

private let KRightWidth : CGFloat        = CMDB_Screen_Width - KSideSlipLeading

class CMDBFilterTableViewCell: CustomBaseCell {
    
    var titleLabel : UILabel!
    
    var detailBtn : UIButton!
    
    var allIamge : UIImageView!
    
    var filterContentCollectionView : CMDBFilterCollectionView!
    
    override func setupCell() {
        super.setupCell()
    }
    
    override func cellBuildSubViews() {
        titleLabel           = UILabel.getInstance()
        
        titleLabel.frame     = CGRect(x: KleftMargin, y: KleftMargin, width: 100, height: 35)
        
        titleLabel.text      = "职业属性"
        
        titleLabel.font      = CMDB_15_FONT
        
        titleLabel.textColor = word87Color
        
        contentView.addSubview(titleLabel)
        
        detailBtn            = UIButton.getInstance()
        
        detailBtn.frame      = CGRect(x: CGRectGetMaxX(titleLabel.frame) + 10, y: KleftMargin, width: KRightWidth, height: 35)
        
        contentView.addSubview(detailBtn)
        
        allIamge             = UIImageView(image:UIImage(named: "进入") , highlightedImage:UIImage(named: "进入 copy"))

        contentView.addSubview(allIamge)
        
        allIamge.snp_makeConstraints { (make) in
            make.right.equalTo(-15);
            make.top.equalTo(20);
            make.height.equalTo(15);
            make.width.equalTo(8);
        }
        
        buildCollectionView()
        
        let singleView = UIView.CreateLine(CGRect(x: 0, y: 0, width: KRightWidth, height: 0.5), lineColor: word38Color)
    
        contentView.addSubview(singleView)
        
        singleView.snp_makeConstraints { (make) in
            make.left.equalTo(0);
            make.bottom.equalTo(0);
            make.width.equalTo(KRightWidth);
            make.height.equalTo(0.5);
        }
    }
    
    override func loadContent() {
    
    }
    
}

extension CMDBFilterTableViewCell{
    
    func buildCollectionView(){
        
        filterContentCollectionView = CMDBFilterCollectionView.getInstance()
        
        filterContentCollectionView.mDelegate = self
        
        filterContentCollectionView.frame = CGRect(x: 0, y: CGRectGetMaxY(self.titleLabel.frame) + 1, width: KRightWidth, height: 100 * CMDB_Rate)
        
        contentView.addSubview(filterContentCollectionView)
    }
}


extension CMDBFilterTableViewCell{
    
    override func onItemClickType(itemClickType: String?, data: AnyObject?, indexPath: NSIndexPath?) {
        printLog("cell")
    }
}
